home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
scope
/
151-175
/
scopedisk168
/
serialrexx
/
eventmanager.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1995-03-19
|
5KB
|
200 lines
/* Event Manager */
/* trace all off */
/* */
/* port 3 port 4 port 5 */
/* */
/* CD Front Door Front Door Stop serial */
/* DSR Kitchen Door Kitchen Door Unused */
/* CTS Sun Room Door Sun Room Door Telephone */
/* */
trace off
portadd = openport( 'EventManager' )
intruder = 0
intruderold = 0
doork = 0
doorf = 0
doors = 0
do until cmd = "STOP"
do until dpacket ~= 0
packet = getpkt( 'EventManager' )
dpacket = c2d( packet )
/* say 'packet is ' dpacket */
if dpacket = 0
then do
flag = waitpkt( 'EventManager' )
end
else do
end
end
/* say 'We now have an event to process. Packet is ' packet dpacket */
string = getarg( packet, 0 )
/* reply to the packet */
flag = reply( packet, 0 )
i = 0
do until blank = 0
/* say 'string is:' string */
blank = index( string, ' ' )
if blank = 0
then do
arg = string
end
else do
arg = substr( string, 1, blank-1 )
string = substr( string, blank+1 )
end
/* say 'Arg is:' arg */
i = i + 1
select
when i = 1 then cmd = arg
when i = 2 then arg1 = arg
when i = 3 then arg2 = arg
when i = 4 then arg3 = arg
when i = 5 then arg4 = arg
otherwise say 'too many arguments'
end
end
select
when cmd = 'SERIAL' then flag = doserial( arg1, arg2, arg3 )
when cmd = 'STOP' then flag = dostop( cmd )
otherwise flag = dounknown( cmd )
end
end
flag = closeport( 'EventManager' )
exit
/* --------------------------------------------------------------- */
doserial: procedure expose intruder intruderold doork doorf doors
arg arg1, arg2, arg3
all = arg1||arg2||arg3
/* say all */
if all = 'CTS51' | all = 'CTS50'
then do
i = dophone( arg3 )
end
else nop
if arg2 = 3 | arg2 = 4
then do
i = dodoor( arg1, arg2, arg3 )
say 'intruder is ' intruder
if intruder & ~ intruderold
then do
address command 'execute s:start intruder'
end
else nop
intruderold = intruder
end
else nop
return 0
/* --------------------------------------------------------------- */
dophone: procedure expose offhook
arg arg3
if arg3 = '0'
then do
say 'hang up phone'
end
else do
say 'answer phone'
address command 'execute x:phone1.scr'
end
return 0
/* --------------------------------------------------------------- */
dodoor: procedure expose intruder doork doorf doors
arg arg1, arg2, arg3
all = arg1||arg2||arg3
opened = 0
closed = 0
if all = 'CD31' | all = 'CD40'
then i = opendoor( arg1 )
else nop
if all = 'DSR31' | all = 'DSR40'
then i = opendoor( arg1 )
else nop
if all = 'CTS31' | all = 'CTS40'
then i = opendoor( arg1 )
else nop
if all = 'CD30' | all = 'CD41'
then i = closedoor( arg1 )
else nop
if all = 'DSR30' | all = 'DSR41'
then i = closedoor( arg1 )
else nop
if all = 'CTS30' | all = 'CTS41'
then i = closedoor( arg1 )
else nop
if closed
then do
if doork = 0 & doorf = 0 & doors = 0
then do
intruder = 0
end
else nop
end
else nop
if opened
then do
intruder = 1
end
else nop
say 'doork doorf doors ' doork doorf doors
return 0
/* --------------------------------------------------------------- */
opendoor: procedure expose opened doork doorf doors
arg door
if door = 'CD'
then do
say 'opened front door'
opened = 1
doorf = 1
end
else nop
if door = 'DSR'
then do
say 'opened kitchen door'
opened = 1
doork = 1
end
else nop
if door = 'CTS'
then do
say 'opened sun room door'
opened = 1
doors = 1
end
else nop
return 0
/* --------------------------------------------------------------- */
closedoor: procedure expose closed doork doorf doors
arg door
if door = 'CD'
then do
say 'closed front door'
closed = 1
doorf = 0
end
else nop
if door = 'DSR'
then do
say 'closed kitchen door'
closed = 1
doork = 0
end
else nop
if door = 'CTS'
then do
say 'closed sun room door'
closed = 1
doors = 0
end
else nop
return 0
/* --------------------------------------------------------------- */
dounknown: procedure
arg cmd
say 'Unknown command: ' cmd
return 0
/* --------------------------------------------------------------- */
dostop: procedure
arg cmd
say 'Preparing to stop.'
return 0
/* --------------------------------------------------------------- */